package cn.hfjava.kz.service.impl;

import cn.hfjava.kz.entity.dto.DocumentQueryDto;
import cn.hfjava.kz.entity.vo.DocumentQueryVo;
import cn.hfjava.kz.entity.vo.PageVO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.hfjava.kz.entity.po.Document;
import cn.hfjava.kz.service.DocumentService;
import cn.hfjava.kz.mapper.DocumentMapper;
import com.github.pagehelper.PageHelper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lds
 * @description 针对表【documents(文档表)】的数据库操作Service实现
 * @createDate 2024-07-23 09:51:13
 */
@Service
public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document>
        implements DocumentService {
    @Resource
    DocumentMapper documentMapper;

    @Override
    public List<Integer> searchIds() {
        return documentMapper.searchIds();
    }

    @Override
    public PageVO<List<DocumentQueryVo>> documentVoList(DocumentQueryDto documentQueryDto) {
        // 1、开启分页
        PageHelper.startPage(documentQueryDto.getCurPage(), documentQueryDto.getPageSize());
        //2、根据组合条件分页查询文档信息
        List<DocumentQueryVo> documentQueryVos = documentMapper.documentVoList(documentQueryDto);
        // 获取总记录数
        long total = documentMapper.getDocumentVoCount(documentQueryDto);
        // 封装分页对象并返回
        PageVO<List<DocumentQueryVo>> listPageVO = new PageVO<>(documentQueryDto.getCurPage(), documentQueryDto.getPageSize(), total, documentQueryVos);
        return listPageVO;
    }
}




